package com.etc.my.service.impl;

import com.etc.my.dao.OrderDao;
import com.etc.my.dto.CountDto;
import com.etc.my.dto.OrderAndCarMessageDto;
import com.etc.my.entity.Order;
import com.etc.my.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderDao dao;

    public OrderDao getDao() {
        return dao;
    }

    public void setDao(OrderDao dao) {
        this.dao = dao;
    }


    @Override
    public boolean insertOrder(Order order) {
        if(order.getOrder_car() == null | order.getOrder_price() == null | order.getOrder_user() == null){
            return false;
        }
        return dao.insertOrder(order);
    }

    @Override
    public List<OrderAndCarMessageDto> getOrderByUserId(Integer userId,Integer page,Integer size) {
        return dao.queryOrderByUserId(userId, page, size);
    }

    @Override
    public CountDto getOrderCountByUserId(Integer userId) {
        return dao.queryOrderCountByUserId(userId);
    }

    @Override
    public boolean deleteOrderById(Integer id) {
        return dao.deleteOrderById(id);
    }
}
